<template>
  <div class="dict-badge">
    <a-badge
      v-if="currentItem"
      :status="currentItem.status ? currentItem.status : 'normal'"
      :text="currentItem.label"
    />
  </div>
</template>

<script setup lang="ts">
import { computed, defineProps } from "vue";

/**
 * 只用于一个数据展示 badge
 */
const props = defineProps({
  // 数据
  options: {
    type: Array,
    default: null
  },
  // 当前的值
  value: [Number, String]
});

// 把 value 转成数组
const currentItem = computed(() => {
  if ((!props.options.length || !props.value) && props.value) {
    return null
  }

  // eslint-disable-next-line
  return props.options.find(i => i.value + '' === props.value + '')
});
</script>

<style scoped lang="less">

</style>
